Many modern computer systems are able to execute more than one distinct software program, or “thread”, without having to explicitly save the state for one thread and restore the state for another thread. For this reason they are referred to as “multi-threaded” computer systems. In one older approach, called sequential multi-threaded operation, the operating system or other control mechanism permits the several threads to share resources by permitting each thread that is a candidate for execution to operate in sequence on the processor. Changing between threads may be referred to as thread switching. In some of these older approaches, threads are switched when the currently executing thread executes for a certain period or reaches a point when it cannot proceed, such as waiting for a memory access or an I/O transfer to finish. The selection of the next thread to be switched in (permitted use of execution resources) may be made on the basis of strict priority. In other approaches, a round-robin approach may be used in thread switching.
Several modern microprocessors support what is known as simultaneous (or concurrent) multi-threaded operation. In these processors, several threads may execute simultaneously sharing resources in parallel rather than in sequence. However, in many cases there will still be more threads that need to be executed than there are hardware execution resources for thread execution. Therefore there will still be a need for thread switching, at least with respect to some resources, when using these processors.
One problem that may arise when thread switching is deadlock. Deadlock may be defined as the condition when a set of processes using shared resources or communicating with each other are permanently blocked.
A similar problem is livelock. Livelock may be defined as the condition when attempts by two or more processes to acquire a resource run indefinitely without any process succeeding.
Thus deadlock and livelock are two examples of potential problems that may arise when switching threads in a multi-threaded system. Improved algorithms for controlling switching threads and algorithms that address deadlock or livelock concerns may continue to be desirable for their ability to improve overall multi-threaded execution.